<?php
include 'Artworks.php';
include 'Artwork.php';
include 'database_connection.php';
class GetArtWork {
	private $db;
	private $pieces;
	private $artwork;
	
	public function __construct() {
		$this->db = DatabaseConn::getInstance();
		$this->pieces = new Artworks();
	}
	
	public function getArt() {
		$result = mysql_query("SELECT * FROM artwork");
		while($row = mysql_fetch_array($result)) {
			
			$art = new Artwork($row['id'],$row['title'], $row['medium'], $row['dimensions'], $row['description'],$row['url'],$row['thumbnail']);
			
			$this->pieces->addToList($art);
			
		}
		
		return $this->pieces->getList();
	}
	
	public function getArtById($id) {
		$result = mysql_query("SELECT * FROM artwork WHERE id='".$id."'");
		$row = mysql_fetch_array($result);
		$art = new Artwork($row['id'],$row['title'], $row['medium'], $row['dimensions'], $row['description'],$row['url'],$row['thumbnail']);
		return $art;
	}
		
}
?>